home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Term / Extras / Source / gtlayout-source.lha / LT_GetMenuItem.c < prev    next >
C/C++ Source or Header  |  1996-08-22  |  2KB  |  73 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #ifdef DO_MENUS
  15.  
  16. /****** gtlayout.library/LT_GetMenuItem ******************************************
  17. *
  18. *   NAME
  19. *    LT_GetMenuItem -- Get the menu/submenu item associated with an ID (V11)
  20. *
  21. *   SYNOPSIS
  22. *    Item = LT_GetMenuItem(Menu,ID)
  23. *     D0                    A0  D0
  24. *
  25. *    struct MenuItem *LT_GetMenuItem(struct Menu *,ULONG);
  26. *
  27. *   FUNCTION
  28. *    This routine scans through all menu items associated with the
  29. *    menu and returns a pointer to the item associated with the
  30. *    given ID value.
  31. *
  32. *   INPUTS
  33. *    Menu - Pointer to Menu structure as returned by LT_NewMenuTagList.
  34. *
  35. *    ID - Unique ID of the item to find.
  36. *
  37. *   RESULT
  38. *    Item - Pointer to the struct MenuItem * in question or NULL
  39. *        if none could be found
  40. *
  41. *   SEE ALSO
  42. *    gtlayout.library/LT_NewMenuTagList
  43. *
  44. ******************************************************************************
  45. *
  46. */
  47.  
  48.     /* LT_GetMenuItem(struct Menu *Menu,ULONG ID):
  49.      *
  50.      *    Obtain the menu item associated with the ID.
  51.      */
  52.  
  53. struct MenuItem * LIBENT
  54. LT_GetMenuItem(REG(a0) struct Menu *Menu,REG(d0) ULONG ID)
  55. {
  56.     RootMenu *Root = (RootMenu *)((ULONG)Menu - offsetof(RootMenu,Menu));
  57.     ItemNode *Item;
  58.  
  59.         // Run down the list...
  60.  
  61.     for(Item = (ItemNode *)Root->ItemList.mlh_Head ; Item->Node.mln_Succ ; Item = (ItemNode *)Item->Node.mln_Succ)
  62.     {
  63.         if(Item->ID == ID)
  64.             return(&Item->Item);
  65.     }
  66.  
  67.         // Nothing found
  68.  
  69.     return(NULL);
  70. }
  71.  
  72. #endif    /* DO_MENUS */
  73.